
package j.util;

import java.io.File;
import java.sql.Timestamp;

/**
 * 
 * @author 肖炯
 *
 */
public final class JUtilUUID {
	private static Object lock = new Object();

	private static int hostUnique = (new Object()).hashCode();
	private static long lastTime = System.currentTimeMillis();
	private static long DELAY = 1L;

	/**
	 * 生成UUID
	 * @return
	 */
	public static String genUUID() {
		synchronized (lock) {
			String uuid=String.join("", Integer.toString(hostUnique, 16), Long.toString(lastTime, 16));
			lastTime+=DELAY;
			return uuid;
		}
	}

	/**
	 * 生成UUID
	 * @return
	 */
	public static String genUUIDShort() {
		synchronized (lock) {
			String uuid=Long.toString(lastTime + DELAY);
			lastTime+=DELAY;
			return uuid;
		}
	}

	public static void main(String[] args) throws Exception{
		File dir = new File("D:/探索/油画与定制/宠物油画/other");
		File[] files = dir.listFiles();
		for(File file : files){
			if(file.isDirectory()) continue;
			if(!file.getName().endsWith(".webp")) continue;

			try {
				System.out.println(file.getAbsolutePath());
				JUtilImage.webp2jpg(file,
						new File("D:/探索/油画与定制/宠物油画/other/" + file.getName().replaceAll("webp", "jpg")),
						1);
			}catch (Exception e){
				e.printStackTrace();
			}
		}
	}
}